<?php
require_once(__PHY_LIB.'/func/Common.func.php');
require_once(__PHY_LIB.'/class/Session.class.php'); new Session();
require_once(__PHY_LIB.'/class/User.class.php');
require_once(__PHY_LIB.'/class/Guest.class.php');
require_once(__PHY_LIB.'/class/Tpl.class.php');

header_nocache();
$oTpl = new MktTpl();
$oTpl->assignConst();
$_The = array();

/// guest or user ///
$rCookie = validate($_COOKIE, 'u_type:e[empty,guest,user]|u_id:n|u_nick:u');
/*
$rCookie = array('u_id' => 100012, 'u_type' => 'guest'); //@ debug
$_COOKIE['u_id'] = 100012; //@ debug
$_COOKIE['u_type'] = 'guest'; //@ debug
 */
if ('user' == $rCookie['u_type']) {
	$oOne = new User($rCookie['u_id']);
	$_The['UserType'] = 'user';
	$_The['User'] = $oOne->getData();
}
elseif ('guest' == $rCookie['u_type']) {
	$oOne = new Guest($rCookie['u_id']);
	$_The['UserType'] = 'guest';
	$_The['User'] = $oOne->getData();
}
else {
	$oOne = Guest::createNew();
	$oOne->saveCookie();
	$_The['UserType'] = 'guest';
	$_The['User'] = $oOne->getData();
}

$oTpl->assign_by_ref('_The', $_The);
?>
